home *** CD-ROM | disk | FTP | other *** search
/ Revista CD Expert 51 / PCGamer51_17Demos.iso / VIDEO / V102401.dxr / 00025_Video Slider.ls < prev    next >
Encoding:
Text File  |  2000-10-03  |  6.6 KB  |  153 lines

  1. property pDuration, pMovieTime, videoSprite, horizontal, extentSprite, hiliteMember, tracking, newLocH, newLocV, sending, dynamic, style, Addressee, name, notify_list, min, max, valrange, minScreen, maxScreen, currentScreenVal, extentlength, CurrentVal
  2.  
  3. on getPropertyDescriptionList
  4.   if the currentSpriteNum = 0 then
  5.     set memdefault to 0
  6.   else
  7.     set memref to the member of sprite the currentSpriteNum
  8.     set memdefault to member (the memberNum of member memref + 1)
  9.   end if
  10.   set description to [:]
  11.   addProp(description, #videoSprite, [#default: 1, #format: #integer, #comment: "Video Sprite:"])
  12.   addProp(description, #extentSprite, [#default: 1, #format: #integer, #comment: "Extent Sprite:"])
  13.   addProp(description, #hiliteMember, [#default: memdefault, #format: #graphic, #comment: "Hilite Member:"])
  14.   addProp(description, #horizontal, [#default: 1, #format: #boolean, #comment: "Horizontal (if not vertical):"])
  15.   addProp(description, #dynamic, [#default: 1, #format: #boolean, #comment: "Dynamic:"])
  16.   return description
  17. end
  18.  
  19. on getBehaviorDescription
  20.   return "Drag to slider 'handle' to enable control of video play time.  Requires additional 'extent' member which limits the handle travel range." & RETURN & "PARAMETERS:" & RETURN & "ΓÇó Video Sprite - Enter the number of sprite channel in which video is displayed." & RETURN & "ΓÇó Extent Sprite -  Enter the number of sprite channel that contains the 'extent' sprite." & RETURN & "ΓÇó Hilite Member -  Member to display while handle is being dragged." & RETURN & "ΓÇó Horizontal - If set, orient extent sprite horizontally, if not set orient vertically." & RETURN & "ΓÇó Dynamic - If set, video time will be updated while handle is dragged, else when handle is released."
  21. end
  22.  
  23. on compute_val me
  24.   set val to 0.0
  25.   set val to float(the currentScreenVal of me) / float(the extentlength of me)
  26.   set val to val * the valrange of me
  27.   set val to val + the min of me
  28.   return val
  29. end
  30.  
  31. on send_the_val me, val
  32.   set pMovieTime to val * pDuration
  33.   videoseek(sprite(videoSprite), pMovieTime)
  34. end
  35.  
  36. on beginSprite me
  37.   set pDuration to the duration of sprite(videoSprite)
  38.   set the min of me to 0.0
  39.   set the max of me to 1.0
  40.   set the sending of me to 1
  41.   set handle to the spriteNum of me
  42.   set the tracking of me to 0
  43.   set the newLocH of me to the locH of sprite handle
  44.   set the newLocV of me to the locV of sprite handle
  45.   if the horizontal of me then
  46.     set the newLocV of me to the locV of sprite the extentSprite of me
  47.     set the minScreen of me to the left of sprite the extentSprite of me
  48.     set the maxScreen of me to the right of sprite the extentSprite of me
  49.   else
  50.     set the newLocH of me to the locH of sprite the extentSprite of me
  51.     set the minScreen of me to the left of sprite the extentSprite of me
  52.     set the maxScreen of me to the right of sprite the extentSprite of me
  53.   end if
  54.   set the locH of sprite handle to the newLocH of me
  55.   set the locV of sprite handle to the newLocV of me
  56.   set the valrange of me to the max of me - the min of me
  57.   set the extentlength of me to the maxScreen of me - the minScreen of me
  58.   if the sending of me = 0 then
  59.     set the dynamic of me to 0
  60.   end if
  61. end
  62.  
  63. on prepareFrame me
  64.   if tracking then
  65.     set handle to the spriteNum of me
  66.     set extent to the extentSprite of me
  67.     if the horizontal of me then
  68.       set the newLocH of me to the mouseH
  69.       set the newLocV of me to the locV of sprite extent
  70.       if the newLocH of me < the left of sprite extent then
  71.         set the newLocH of me to the left of sprite extent
  72.       end if
  73.       if the newLocH of me > the right of sprite extent then
  74.         set the newLocH of me to the right of sprite extent
  75.       end if
  76.       set the currentScreenVal of me to the newLocH of me - the minScreen of me
  77.     else
  78.       set the newLocH of me to the locH of sprite extent
  79.       set the newLocV of me to the mouseV
  80.       if the newLocV of me < the top of sprite extent then
  81.         set the newLocV of me to the top of sprite extent
  82.       end if
  83.       if the newLocV of me > the bottom of sprite extent then
  84.         set the newLocV of me to the bottom of sprite extent
  85.       end if
  86.       set the currentScreenVal of me to the newLocV of me - the minScreen of me
  87.     end if
  88.     set the locH of sprite handle to the newLocH of me
  89.     set the locV of sprite handle to the newLocV of me
  90.     if the dynamic of me then
  91.       send_the_val(me, compute_val(me))
  92.     end if
  93.   else
  94.     set x to float(the currentTime of sprite(videoSprite)) / float(pDuration)
  95.     set handle to the spriteNum of me
  96.     set extent to the extentSprite of me
  97.     if the horizontal of me then
  98.       set ScreenX to the left of sprite extent + (x * (the right of sprite extent - the left of sprite extent))
  99.       set the newLocH of me to ScreenX
  100.       set the newLocV of me to the locV of sprite extent
  101.       if the newLocH of me < the left of sprite extent then
  102.         set the newLocH of me to the left of sprite extent
  103.       end if
  104.       if the newLocH of me > the right of sprite extent then
  105.         set the newLocH of me to the right of sprite extent
  106.       end if
  107.       set the currentScreenVal of me to the newLocH of me - the minScreen of me
  108.     else
  109.       set ScreenY to the top of sprite extent + (x * (the bottom of sprite extent - the top of sprite extent))
  110.       set the newLocH of me to the locH of sprite extent
  111.       set the newLocV of me to ScreenY
  112.       if the newLocV of me < the top of sprite extent then
  113.         set the newLocV of me to the top of sprite extent
  114.       end if
  115.       if the newLocV of me > the bottom of sprite extent then
  116.         set the newLocV of me to the bottom of sprite extent
  117.       end if
  118.       set the currentScreenVal of me to the newLocV of me - the minScreen of me
  119.     end if
  120.     set the locH of sprite handle to the newLocH of me
  121.     set the locV of sprite handle to the newLocV of me
  122.   end if
  123. end
  124.  
  125. on mouseDown me
  126.   set tracking to 1
  127.   set temp to the member of sprite the spriteNum of me
  128.   set the member of sprite the spriteNum of me to member the hiliteMember of me
  129.   set the hiliteMember of me to temp
  130. end
  131.  
  132. on mouseUp me
  133.   set tracking to 0
  134.   set temp to the member of sprite the spriteNum of me
  135.   set the member of sprite the spriteNum of me to member the hiliteMember of me
  136.   set the hiliteMember of me to temp
  137.   if the sending of me then
  138.     set x to compute_val(me)
  139.     send_the_val(me, x)
  140.   end if
  141. end
  142.  
  143. on mouseUpOutSide me
  144.   set tracking to 0
  145.   set temp to the member of sprite the spriteNum of me
  146.   set the member of sprite the spriteNum of me to member the hiliteMember of me
  147.   set the hiliteMember of me to temp
  148.   if the sending of me then
  149.     set x to compute_val(me)
  150.     send_the_val(me, x)
  151.   end if
  152. end
  153.